import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton,QMessageBox
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
from PythonApplication1 import WMXYAutoSign
import uiautomator2 as u2
class App(QWidget):

    def __init__(self):
        super().__init__()
        self.title = 'WMXYHelper PoWeR bY-Rrrrrrust'
        self.left = 300
        self.top = 300
        self.width = 500
        self.height = 500
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        button = QPushButton('测试设备连通性', self)
        button.setToolTip('Test Device Connect Status')
        button.move(100,70)
        button.clicked.connect(self.on_click_testPassProcess)

        self.show()

    def on_click_testPassProcess(self):
        try:
            d = u2.connect()
        except:
            QMessageBox.critical(self, "Critical", "连接异常，检查USB是否连接好及USB调试是否打开！")
            return
        WMXYAutoSign.sign(d)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = App()
    sys.exit(app.exec_())